#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

void move(char pos1, char pos2)
{
	printf("%c -> %c\n", pos1, pos2);
}

void Hanoi(int n,char A,char B,char C)
{
	if (n == 1)
	{
		move(A,C);
	}
	else {
		Hanoi(n - 1, A, C, B);
		move(A, C);
		Hanoi(n - 1, B, A, C);
	}
	
}

int main()
{
	int m = 0;

	scanf("%d", &m);

	Hanoi(m, 'A', 'B', 'C');

	return 0;
}